package net.tv90.bfmccore.game.impl;

import net.tv90.bfmccore.game.impl.cq.ConquestArea;
import net.tv90.bfmccore.game.impl.cq.FrontLineConquestArea;
import net.tv90.bfmccore.util.HUD.ImageShow;
import net.tv90.bfmccore.util.vector.Vector2i;
import net.tv90.bfmccore.util.vector.Vector3i;

import java.util.ArrayList;
import java.util.List;

public class FrontLineGame extends ConquestGame {

    List<ImageShow> leftArrows = new ArrayList<>();

    List<ImageShow> rightArrows = new ArrayList<>();


    @Override
    public void initGameSource(String mapName, String gameMode, String firstFactionName, String secondFactionName, Vector3i mainSpawnPoint, Vector3i firstFactionMainSpawnPoint, Vector3i secondFactionMainSpawnPoint, List<ConquestArea> list) {
        super.initGameSource(mapName, gameMode, firstFactionName, secondFactionName, mainSpawnPoint, firstFactionMainSpawnPoint, secondFactionMainSpawnPoint, list);
    }

    @Override
    public void showGameInfo() {
        super.showGameInfo();
        rightArrows.forEach((I) -> {
            I.showToPlayers(firstFactionList);
        });
        leftArrows.forEach((I) -> {
            I.showToPlayers(secondFactionList);
        });
    }

    @Override
    public void initImageSource(List<ConquestArea> list) {
        ImageShow[] pointImageList = new ImageShow[list.size()];
        int imageScale = 15;
        for (int i = 0; i < list.size(); i++) {
            pointImageList[i] = new ImageShow(new Vector2i((int) (427 + imageScale / 2 + (i - (float) pointImageList.length / 2.0F) * 40), 40)
                    , new Vector2i(imageScale, imageScale), "", 1, "Point" + i);
            conquestAreaList.put(list.get(i), pointImageList[i]);
        }

        for (int i = 2; i < list.size() - 1; i++) {
            leftArrows.add(
                    new ImageShow(new Vector2i(((int) (427 + imageScale / 2 + (i - (float) pointImageList.length / 2.0F) * 40) - 20), 40)
                            , new Vector2i(imageScale, imageScale), "[local]BattleField/l_arrow.png", 1, "l_arrow" + i)
            );
            rightArrows.add(
                    new ImageShow(new Vector2i(((int) (427 + imageScale / 2 + (i - (float) pointImageList.length / 2.0F) * 40) - 20), 40)
                            , new Vector2i(imageScale, imageScale), "[local]BattleField/r_arrow.png", 1, "r_arrow" + i)
            );
        }
    }

    @Override
    public String getGameInfo() {
        return "FrontLine " + mapName + " " + currentTime + " " + firstFactionName + ':' + firstFactionTicket + ' ' + secondFactionName + ':' + secondFactionTicket;
    }
}
